﻿using System.Text.Json.Serialization;

namespace DimensionsHelper.Client.WinUi.Services;

public class OptionalFileStorage
{
    private HashSet<string> _history = new(StringComparer.OrdinalIgnoreCase);
    private HashSet<string> _preset = new(StringComparer.OrdinalIgnoreCase);


    public string Root { get; set; } = string.Empty;

    public List<string> History
    {
        get => _history.ToList();
        set => _history = new HashSet<string>(value, StringComparer.OrdinalIgnoreCase);
    }

    public List<string> Preset
    {
        get => _preset.ToList();
        set => _preset = new HashSet<string>(value, StringComparer.OrdinalIgnoreCase);
    }

    [JsonIgnore]
    public bool HasHistory => _history.Count > 0;

    public bool AddHistory(string fileName) => _history.Add(fileName);

    public bool RemoveHistory(string fileName) => _history.Remove(fileName);

    public void RemoveAllHistory() => _history.Clear();

    public bool IsHistory(string fileName) => _history.Contains(fileName);

    public bool AddPreset(string fileName) => _preset.Add(fileName);

    public bool RemovePreset(string fileName) => _preset.Remove(fileName);

    public bool IsPreset(string fileName) => _preset.Contains(fileName);
}